#include <stdio.h>
#include "textures.h"

texture_t wallTextures[NUM_TEXTURES];

static const char* textureFileNames[NUM_TEXTURES] =
{
  "images/brick.png",
  "images/vent.png",
  "images/mossystone.png",
  "images/graystone.png",
  "images/colorstone.png",
  "images/bluestone.png",
  "images/wood.png",
  "images/poison.png",
  "images/mask.png"
};


void loadWallTextures() {
  int i=0;
  for(i=0; i< NUM_TEXTURES; i++) {
    upng_t* upng;
    upng = upng_new_from_file(textureFileNames[i]);
    if (upng != NULL) {
      upng_decode(upng);
      if (upng_get_error(upng) == UPNG_EOK) {
        wallTextures[i].upngTexture = upng;
        wallTextures[i].width = upng_get_width(upng);
        wallTextures[i].height = upng_get_height(upng);
        wallTextures[i].texture_buffer = (colour_t*)upng_get_buffer(upng);
      }
    }
  }
}

void freeWallTextures() {
  int i=0;
  for(i=0; i< NUM_TEXTURES; i++) {
    upng_free(wallTextures[i].upngTexture);
  }
}
